import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: \
 * Date: 2024-09-24
 * Time: 9:28
 */
public class Josephus {
    public Josephus(int n, int start, int distance) {
        ArrayList<String> arrayList = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            arrayList.add((char)('A'+i) + " ");//插入数据
        }
        System.out.println(arrayList.toString());
        int i = start;
        int size = arrayList.size();
        while(size > 1){
            i = (i + distance -1) % size;
            System.out.println("删除" + arrayList.remove(i));
            System.out.println(arrayList.toString());
            size--;
        }
        System.out.println("最后一个是：" + arrayList.get(0).toString());
    }

    public static void main(String[] args) {
        new Josephus(8,1,3);
    }
}
